/**
 * 
 */

var pageIndex;
$(function() {
	$("#modifyPwdForm").validate({
		rules : {
			'oldPwd' : {
				required : true
			},
			'pwd' : {
				required : true
			},
			'confirmPwd' : {
				required : true
			}
		},
		submitHandler : function(form) {
			
			if($("input[name='pwd']").val()!=$("input[name='confirmPwd']").val()){
				$.warn("两次密码不一致");
				return ;
			}
			
			var options = {
				url : ctx+"/admin/sys/user/modifyPwd",
				type : "post",
				dataType : "json",
				success : function(data) {
					if (data.success) {
						$.success('操作成功', function() {
							window.location.href=ctx+"/loginOut";
						});
					} else {
						$.error(data.msg);
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$.warn('服务忙,请稍后再试.');
				}
			};
			$(form).ajaxSubmit(options);
		},
		invalidHandler : function(form, validator) {

			return false;
		}

	});

});

function modifyPwd() {
	pageIndex =layer.open({
		type : 1,
		title : '修改密码',
		shadeClose : true,
		shade : 0.5,
		area : [ '500px', '350px' ],
		content : $('#modifyPwd')
	});

}